package homework01;

public class Circle extends shape {
    private double radius;

    public Circle(double x, double y, double radius) {
        super(x, y);
        this.radius = radius;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    @Override
    public double getArea() {
        return Math.PI * radius * radius;
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("circle{x=");
        stringBuilder.append(getX());
        stringBuilder.append(", y=");
        stringBuilder.append(getY());
        stringBuilder.append(",radius=");
        stringBuilder.append(getRadius());
        stringBuilder.append("}");
        return stringBuilder.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Circle circle)) return false;

        return Double.compare(circle.radius, radius) == 0;
    }
}
